package agents;

import negotiator.Bid;

/**
 *
 * @author Oliver Trinnes, Thomas Nowicki, Felix Remmel, Ruben Schwarzwald
 */
public class Sort
{
  public static void bubbleSort(Bid[] bids, double[] frequencies)
  {
    int n = bids.length;
    while(true)
    {
      boolean swapped = false;
      for(int i = 1; i<n; i++)
      {
        if(frequencies[i-1] < frequencies[i])
        {
          swap(bids, frequencies, i-1, i);
          swapped = true;
        }
      }
      n = n-1;
      if(!swapped)
        break;
    }
  }
  private static void swap(Bid[] array1, double[] array2, int i, int j)
  {
    Bid tempMove = array1[i];
    double tempValue = array2[i];
    
    array1[i] = array1[j];
    array2[i] = array2[j];
    array1[j] = tempMove;
    array2[j] = tempValue;
  }
}
